package com.pillar.handler;

import com.pillar.game.Cmd;
import com.pillar.game.NodeStatus;
import com.pillar.request.BasePackage;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;

import java.util.UUID;

/**
 * @author pillar
 * @desc
 * @email: 347637454@qq.com
 * @createDate 2021-01-04 15:49
 */
@Slf4j
public class LoginHandler extends AbstractCheckLoginHandler {
    @Override
    public boolean apply(BasePackage basePackage) {
        return Cmd.LOGIN.equals(basePackage.getCmd());
    }

    @Override
    public boolean consume(Channel channel, BasePackage basePackage) {
        log.info("玩家登录大厅={}",basePackage);
        basePackage.setUuid(UUID.randomUUID().toString());
        NodeStatus.addChannel(channel,basePackage.getUuid());
        writeText(channel,"登录成功,uuid="+basePackage.getUuid());
        return false;
    }
}
